﻿using System;
using Fly.Data;
using FlyWebFrame.Model;

namespace FlyWebFrame.Action.admin
{
    public class partners : baseaction
    {
        public dynamic partnerlist;
        public int pageindex;
        public int pageindexview;

        public override void Treat()
        {
            contentleft = "/html/admin/partners.htm";
            page_title = "LEAD Consulting - Quản lý đối tác";
            admin_script = "$('#ad_partner').addClass('active');";

            Int32.TryParse(GetParameter(1), out pageindex);
            pageindexview = pageindex + 1;

            Categories categories = new Categories();
            dynamic cat = categories.GetPartners().Data;

            String ids = "-1";
            for (int i = 0; i < cat.Length; i++)
            {
                ids += "," + cat[i].id;
            }

            News news = new News();
            partnerlist = news.GetByBigCat(ids, pageindex, 10).Data;

            for (int i = 0; i < partnerlist.Length; i++)
            {
                for (int j = 0; j < cat.Length; j++)
                {
                    if (partnerlist[i].catId == cat[j].id)
                    {
                        partnerlist[i].catName = cat[j].viName;
                    }
                }
            }
        }
    }
}